<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>拍卖设置</title>
    <link rel="stylesheet" href="../css/common.css">
    <link rel="stylesheet" href="../css/page.css">
    <link rel="stylesheet" href="../css/lCalendar.css">
    <script src="../js/jquery-3.2.1.min.js"></script>
    <script src="../js/media.js"></script>
    <script src="../js/common.js"></script>
    <script src="../js/lCalendar.js"></script>
    <style>
        .section2 input {
            text-align: right;
        }

        .checked {}
    </style>
</head>

<body>
    <!--头部-->
    <div class="public-header flex">
        <!--<span class="public-header-left-search"></span>-->
        <span class="public-header-left-back"></span>
        <span class="public-header-center">拍卖设置</span>
        <span class="public-header-right">保存</span>
    </div>

    <!--正文-->
    <div class="Shop-settings bc-gray">
        <section class="section1">
            <ul>
                <li class="flex">
                    <span>店铺折扣</span>
                    <div class="checkbox checkbox-slider--b-flat">
                        <label>
				<input type="checkbox" id="check"><span></span>
			</label>
                    </div>
                </li>

            </ul>
        </section>
        <p class="t1" style="text-align:right;">截止时间在折扣期内的，均享受折扣</p>
        <section class="section2">
            <ul>

                <li class="flex">
                    <span>折扣率</span>
                    <em style="background:none;"><input type="text" placeholder="100" disabled="disabled" id="rate"></em>
                </li>
                <li class="flex">
                    <span>开始时间</span>
                    <em>
                        <!-- <input type="text" placeholder="时间格式：xxxx-xx-xx" disabled="disabled" id="s_d"> -->
                        <input style="color: #999999; text-align: right;" class="weui-input weui-cell__ft" disabled="disabled" id="s_d" type="text" readonly="" name="input_date" placeholder="日期选择特效" data-lcalendar="2011-01-1,2020-12-31" />
                    </em>
                </li>
                <li class="flex">
                    <span>结束时间</span>
                    <em>
                            <!-- <input type="text" placeholder="时间格式：xxxx-xx-xx" disabled="disabled" id="e_d"> -->
                            <input style="color: #999999; text-align: right;" class="weui-input weui-cell__ft" disabled="disabled" id="e_d" type="text" readonly="" name="input_date" placeholder="日期选择特效" :data-lcalendar="2011-01-1,2020-12-31" />
                    </em>
                </li>

            </ul>
        </section>



    </div>




    <script>
        $(function () {
            var calendar = new lCalendar();
            calendar.init({
                'trigger': '#s_d',
                'type': 'date'
            });
            var calendardatetime = new lCalendar();
            calendardatetime.init({
                'trigger': '#e_d',
                'type': 'datetime'
            });

            $('#check').click(function () {
                $(this).toggleClass('checked');
                if ($(this).hasClass('checked')) {
                    $('.section2 input').removeAttr('disabled')
                } else {
                    $('.section2 input').attr('disabled', 'disabled')
                }
            })
            $('.public-header-right').click(function () {
                let rate = $('#rate').val();
                let s_d = new Date($('#s_d').val() + ' 00:00:00:00');
                let e_d = new Date($('#e_d').val() + ' 00:00:00:00');
                if ($('#check').hasClass('checked')) { 
                    $.ajax({
                        url: base_url + 'ZITAOHUI/store/discount',
                        data: {
                            store_id: s_id,
                            is_discount_rate: 1,
                            discount_rate: rate,
                            start_time: s_d,
                            end_time: e_d,
                        },
                        success: function (data) {
                            console.log(data)
                            if (data.code == 1) {
                                window.location.href = '../page/setting-center.html'
                            }
                        },
                        error: function (data) {
                            console.error(data)
                        }
                    })
                } else { 
                    window.location.href = '../page/setting-center.html'
                }
            })
        })
    </script>
</body>

</html>